package org.komarichin.jpa.dao;

import org.komarichin.jpa.entity.IRole;

import java.io.Serializable;
import java.util.List;

/**
 * User: Michael Komarichin
 * Date: 28.09.2009
 * Time: 13:12:35
 */
public interface IRoleDAO extends Serializable {
    /**
     * find role by id
     *
     * @param id role id
     * @return found role
     */
    IRole getRoleById(Long id);

    /**
     * fidn role by name
     *
     * @param name role name
     * @return found role or null
     */
    IRole getRoleByName(String name);

    /**
     * create role
     *
     * @param name       role name
     * @param permission role permission
     * @return created role
     */
    IRole createRole(String name, Long permission);

    /**
     * @return all roles
     */
    List<IRole> getAll();

    /**
     * find role for users
     *
     * @param permission user permission
     * @return found roles
     */
    List<IRole> getAllowRoles(Long permission);

    /**
     * @param object saved role
     */
    void save(IRole object);

    /**
     * @param object updated role
     */
    void update(IRole object);

    /**
     * @param object save or update role, if role exist then update
     */
    void saveOrUpdate(IRole object);

    /**
     * @param object delete role
     */
    void delete(IRole object);
}
